import { defineComponent, ref, onMounted, watch, computed, openBlock, createElementBlock, normalizeClass, createElementVNode, toDisplayString, createCommentVNode } from "vue";
import dayjs from "dayjs";
const _hoisted_1 = { class: "me-date-text" };
const _hoisted_2 = {
  key: 0,
  class: "me-date-week"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...{
    name: "me-date"
  },
  __name: "date",
  props: {
    format: { type: [String, Function], default: "YYYY-MM-DD HH:mm:ss" },
    layout: { default: "horizontal" },
    weeked: { type: Boolean, default: false }
  },
  setup(__props) {
    const props = __props;
    const date = ref("");
    const week = ref("");
    onMounted(() => {
      setDate();
    });
    watch(() => props.format, () => {
      const day = dayjs();
      date.value = day.format(typeof props.format === "function" ? props.format(day) : props.format);
    });
    const setDate = () => {
      const day = dayjs();
      date.value = day.format(typeof props.format === "function" ? props.format(day) : props.format);
      week.value = getWeek(dayjs().day());
      setTimeout(setDate, 500);
    };
    const getWeek = (day) => {
      const weekMap = {
        0: "星期日",
        1: "星期一",
        2: "星期二",
        3: "星期三",
        4: "星期四",
        5: "星期五",
        6: "星期六"
      };
      return weekMap[day];
    };
    const getLayoutClass = computed(() => {
      return props.layout;
    });
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", {
        class: normalizeClass(["me-date", getLayoutClass.value])
      }, [
        createElementVNode("span", _hoisted_1, toDisplayString(date.value), 1),
        _ctx.weeked ? (openBlock(), createElementBlock("span", _hoisted_2, toDisplayString(week.value), 1)) : createCommentVNode("", true)
      ], 2);
    };
  }
});
export {
  _sfc_main as default
};
//# sourceMappingURL=date.vue2.mjs.map
